<%--
   For com.football
   Copyright [2015/11/13] By RICK
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../../common/base_body_header.jsp" %>
<%@include file="../../common/navbar.jsp" %>
<%@include file="../../common/page_content_pre.jsp" %>
<div class="page-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="widget-box">
                <div class="widget-header">
                    <h4>编辑角色</h4>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <form:form class="form-horizontal" modelAttribute="sysRole"
                                   action="${GLOBAL.basePath}/sysrole/save" method="post" id="sysRoleForm">
                            <form:hidden path="roleId"/>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">角色名称：</label>

                                    <div class="col-sm-5">
                                        <input id="oldName" name="oldName" type="hidden" value="${sysRole.roleName}">
                                        <form:input path="roleName" htmlEscape="false" maxlength="50"
                                                    class="input-xlarge required" placeholder="请输入角色名称"/>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>
                            <%--<fieldset>--%>
                                <%--<div class="form-group">--%>
                                    <%--<label class="col-sm-3 control-label">是否系统数据：</label>--%>

                                    <%--<div class="col-sm-8">--%>
                                        <%--<form:select path="sysData">--%>
                                            <%--<form:options items="${fns:getDictList('YES_NO')}" itemLabel="value"--%>
                                                          <%--itemValue="name" htmlEscape="false"/>--%>
                                        <%--</form:select>--%>
                                        <%--<span class="help-inline">“是”代表此数据只有超级管理员能进行修改，“否”则表示拥有角色修改人员的权限都能进行修改</span>--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                            <%--</fieldset>--%>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">角色状态：</label>

                                    <div class="col-sm-5">
                                        <label class="inline">
                                            <input name="delFlag" type="radio" value="0"
                                                   class="ace" ${sysRole.delFlag  ? '':'checked' } />
                                            <span class="lbl">启用</span>
                                        </label>
                                        <label class="inline">&nbsp;&nbsp;</label>
                                        <label class="inline">
                                            <input name="delFlag" type="radio" value="1"
                                                   class="ace" ${sysRole.delFlag  ? 'checked':'' } />
                                            <span class="lbl">禁用</span>
                                        </label>
                                        <span class="help-inline">“启用”代表此数据可用，“禁用”则表示此数据不可用</span>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">备注：</label>

                                    <div class="col-sm-4">
                                        <form:textarea path="remark" htmlEscape="false" rows="3" maxlength="200"
                                                       class="input-xlarge"/>
                                    </div>
                                </div>
                            </fieldset>
                            <div class="form-actions center">
                                <button type="button" class="btn btn-sm btn-grey" id="go_back_btn">
                                    返回
                                    <i class="icon-reply icon-on-right bigger-110"></i>
                                </button>
                                <shiro:hasPermission name='sys:role:edit'>
                                    <button type="submit" class="btn btn-sm btn-success" id="save_btn">
                                        保存
                                        <i class="icon-save icon-on-right bigger-110"></i>
                                    </button>
                                </shiro:hasPermission>
                            </div>
                        </form:form>
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>

<%@include file="../../common/page_content_suf.jsp" %>
<%@include file="../../common/script1.jsp" %>

<script type="text/javascript">
    $(document).ready(function () {
        $("#roleName").focus();
        $("#sysRoleForm").validate({
            rules: {
                roleName: {
                    remote: {
                        type: "POST",
                        cache: false,
                        url: "${GLOBAL.basePath}/sysrole/checkName",
                        data: {
                            oldName: function () {
                                return "${sysRole.roleName}";
                            }
                        }
                    }
                }
            },
            messages: {
                roleName: {required: "角色名不能为空", remote: jQuery.format("角色名已存在")}
            },
            submitHandler: function (form) {
                var ids = [], nodes = tree.getCheckedNodes(true);
                for (var i = 0; i < nodes.length; i++) {
                    ids.push(nodes[i].id);
                }
                $("#resourceIds").val(ids);
                loading('正在提交，请稍等...');
                form.submit();
            },
            errorContainer: "#messageBox",
            errorPlacement: function (error, element) {
                $("#messageBox").text("输入有误，请先更正。");
                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                    error.appendTo(element.parent().parent());
                } else {
                    error.insertAfter(element);
                }
            }
        });

        $("#go_back_btn").on("click", function () {
            goBack();
        });
    });

    function goBack() {
        document.location.href = "${GLOBAL.basePath}/sysrole/list";
    }
</script>
